<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex flex-wrap align-center justify-between benben-position-layout flex forgetPasswords_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center forgetPasswords_fd0_0' @tap.stop="handleJumpDiy"
					data-type="back" data-url="1">
					<image class='forgetPasswords_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"160.png"'></image>
				</view>
				<view class='flex flex-wrap align-center forgetPasswords_fd0_0'>
				</view>
			
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout register_flex_0">
				<view class='flex flex-wrap align-center justify-center register_fd0_0'>
					<image class='register_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"7.png"'></image>
				</view>
				<view class='flex flex-wrap align-center register_fd0_1'>
					<image class='register_fd0_1_c0' mode="aspectFit" :src='STATIC_URL+"2.png"'></image>
					<input class='flex-sub register_fd0_1_c1' type="number" :placeholder="`请输入手机号`" confirm-type="done"
						:maxlength="11" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
						v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center register_fd0_1'>
					<image class='register_fd0_1_c0' mode="aspectFit" :src='STATIC_URL+"9.png"'></image>
					<input class='flex-sub register_fd0_2_c1' type="number" :placeholder="`请输入验证码`" confirm-type="done"
						:maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
						v-model="code" />
					<benben-send-verification-code class=' register_fd0_2_c2' after-text='后重新获取' before-text='获取验证码'
						type='1' :phone="mobile"></benben-send-verification-code>
				</view>
				<view class='flex flex-wrap align-center register_fd0_1'>
					<image class='register_fd0_1_c0' mode="aspectFit" :src='STATIC_URL+"3.png"'></image>
					<benben-flex-password-diy v-model="password" class-name="flex flex align-center register_fd0_3_c1"
						:placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
						<template #show>
							<text class='fu-iconfont2  register_fd0_3_c1_icon1' data-type="show">&#xE837;</text>
						</template>
						<template #hide>
							<text class='fu-iconfont2  register_fd0_3_c1_icon1' data-type="hide">&#xEBCC;</text>
						</template>
					</benben-flex-password-diy>
				</view>
				<button class='register_fd0_4' @tap.stop="registerFunc()">注册</button>
				<view class='flex flex-wrap align-center justify-center register_fd0_5'>
					<benben-flex-switch-new class-name='flex flex' v-model="is_tk" :disabled='false'>
						<template v-slot:checked>

							<view class='flex flex position-relative align-center'>
								<image class='register_checkfd0_5_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"8.png"'>
								</image>
							</view>

						</template>
						<template v-slot:unchecked>

							<view class='flex flex position-relative justify-end align-center'>
								<image class='register_noCheckfd0_5_c0_c1_c0' mode="aspectFit"
									:src='STATIC_URL+"6.png"'></image>
							</view>

						</template>
					</benben-flex-switch-new>
					<text class='register_fd0_5_c1'>已阅读并同意</text>
					<text class='register_fd0_5_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/dlzc/agreements/agreements`">《用户注册协议》</text>
					<text class='register_fd0_5_c3'>与</text>
					<text class='register_fd0_5_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/dlzc/privacyPolicy/privacyPolicy`">《隐私政策》</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"is_tk": false,
				"mobile": "",
				"code": "",
				"password": "",
				"dataList": {
					"userinfo": {
						"user_token": "",
						"id": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": ""
					}
				},
				"invite_code": ""
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//注册
			async registerFunc() {
				if (this.is_tk === false) {
					this.$message.info('请勾选用户协议');
					return false;
				}
				if (!validate(this.mobile, 'require')) {
					this.$message.info('请输入手机号');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('请输入验证码');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('密码格式错误');
					return false;
				}
				if (this.is_tk === false) {
					this.$message.info('请勾选协议');
					return false;
				}
				//请求方法
				//数据验证

				let datadataList = await this.$api.post(global.apiUrls.post5cad9f63e4f94, {
					mobile: this.mobile,
					code: this.code,
					password: this.password,
					invite_code: this.invite_code
				});
				if (datadataList.data.code != 1) {
					this.$message.info(datadataList.data.msg);
					return
				}
				let infodataList = datadataList.data.data.userinfo;
				this.dataList = infodataList
				this.$store.commit('saveToken', infodataList.user_token)
				this.$store.commit('updateUserInfo', infodataList)
				uni.navigateTo({
					url:'/pages/grzx/selectIdentity/selectIdentity'
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto;
	}
	
	.forgetPasswords_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}
	
	.forgetPasswords_fd0_0_c0 {
		width: 20rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx 32rpx;
	}
	
	.forgetPasswords_fd0_0 {
		width: 100rpx;
		height: 88rpx;
	}

	.register_flex_0 {
		padding: 0rpx 56rpx 0rpx 56rpx;
	}

	.register_fd0_5_c3 {
		color: var(--benbenFontColor2);
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.register_fd0_5_c2 {
		color: rgba(252, 95, 128, 1);
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.register_fd0_5_c1 {
		color: var(--benbenFontColor2);
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
	}

	.register_noCheckfd0_5_c0_c1_c0 {
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		width: 32rpx;
		height: 32rpx;
	}

	.register_checkfd0_5_c0_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
	}

	.register_fd0_5 {
		width: 750rpx;
		position: fixed;
		bottom: calc(29rpx + var(--window-bottom));
		left: 0rpx;
		width: 100%;
	}

	.register_fd0_4 {
		background: #FC5F80;
		border-radius: 60rpx 60rpx 60rpx 60rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		width: 638rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin: 112rpx 0rpx 32rpx 0rpx;
	}

	.register_fd0_3_c1_icon1 {
		width: 44rpx;
		line-height: 44rpx;
		text-align: center;
		font-size: 40rpx;
	}

	::v-deep .register_fd0_3_c1 {
		width: 569rpx;
		font-size: 32rpx;
		margin: 0rpx 0rpx 0rpx 28rpx;
	}

	.register_fd0_2_c2 {
		line-height: 40rpx;
		font-size: 28rpx;
		color: var(--benbenFontColor0);
		font-weight: 400;
	}

	.register_fd0_2_c1 {
		margin: 0rpx 0rpx 0rpx 28rpx;
		color: var(--benbenFontColor0);
		font-size: 28rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.register_fd0_1_c1 {
		margin: 0rpx 0rpx 0rpx 28rpx;
		color: var(--benbenFontColor0);
		font-size: 32rpx;
		font-weight: 400;
		line-height: 40rpx;
	}

	.register_fd0_1_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.register_fd0_1 {
		border-bottom: 1px solid #eee;
		background: #FFFFFF;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.register_fd0_0_c0 {
		width: 180rpx;
		height: 180rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.register_fd0_0 {
		margin: 150rpx 0rpx 80rpx 0rpx;
	}

	.register_flex_1 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}

	.register_fd1_0 {
		width: 100rpx;
		height: 88rpx;
	}
</style>